package com.oneday.nuo.base.controller;


import com.oneday.nuo.base.dto.NuoRoleDTO;
import com.oneday.nuo.base.entity.NuoRoleEntity;
import com.oneday.nuo.base.response.NuoResult;
import com.oneday.nuo.base.service.NuoRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 角色表(NuoRole)表控制层
 *
 * @author liushuai
 * @since 2021-03-13 23:37:26
 */
@RestController
@RequestMapping("api/role")
@Api(tags="NuoRoleController")
@ApiModel(value = "",description = "角色表")
public class NuoRoleController {
    @Autowired
    private NuoRoleService nuoRoleService;

    @ApiOperation(value = "保存角色" ,  notes="保存角色")
    @PostMapping("saveRole")
    public NuoResult saveRole(@RequestBody NuoRoleDTO nuoRoleDTO){
        nuoRoleService.saveRole(nuoRoleDTO);
        return NuoResult.buildResponseSave();
    }

    @ApiOperation(value = "根据id删除角色" ,  notes="根据id删除角色")
    @GetMapping("deleteRoleById")
    public NuoResult deleteRoleById(@RequestParam String id){
         nuoRoleService.deleteById(id);
        return NuoResult.buildResponseDelete();
     }
     @ApiOperation(value = "根据id查询角色" ,  notes="根据id查询角色")
     @GetMapping("queryRoleById")
     public NuoResult<NuoRoleEntity> queryRoleById(@RequestParam String id){
         NuoRoleEntity entity = nuoRoleService.queryRoleById(id);
        return NuoResult.buildResponseQuery(entity);
     }
    @ApiOperation(value = "根据参数分页查询角色" ,  notes="根据参数分页查询角色")
    @GetMapping("queryRolePageByParam")
     public NuoResult<List<NuoRoleEntity>> queryRolePageByParam(Map<String,Object> param){
        List<NuoRoleEntity> list = nuoRoleService.queryRolePageByParam(param);
        return NuoResult.buildResponseQuery(list);
     }

    @ApiOperation(value = "查询所有角色" ,  notes="查询所有角色")
    @GetMapping("queryRoleAll")
    public NuoResult<List<NuoRoleEntity>> queryRoleAll(){
        List<NuoRoleEntity> list = nuoRoleService.queryRoleAll();
        return NuoResult.buildResponseQuery(list);
    }





}